<?php

namespace services\common;

use Yii;
use common\components\Service;
use common\enums\DevPatternEnum;
use common\enums\AppEnum;

/**
 * 开发模式
 *
 * Class DevPatternService
 * @package services\common
 * @author YiiFrame <21931118@qq.com>
 */
class DevPatternService extends Service
{
    /**
     * 判断多企业
     *
     * @return bool
     */
    public function isB2B2C()
    {
        return Yii::$app->params['devPattern'] === DevPatternEnum::B2B2C;
    }

    /**
     * @return bool
     */
    public function isB2C()
    {
        return Yii::$app->params['devPattern'] === DevPatternEnum::B2C;
    }

    /**
     * @return bool
     */
    public function isSAAS()
    {
        return Yii::$app->params['devPattern'] === DevPatternEnum::SAAS;
    }

    /**
     * 判断是否平台不可见
     *
     * @return bool
     */
    public function isNotPlatformFunction()
    {
        return ($this->isB2C() || ($this->isB2B2C() && Yii::$app->id == AppEnum::MERCHANT));
    }

    /**
     * 判断是否只有企业可用功能
     *
     * @return bool
     */
    public function isMerchantFunction()
    {
        return ($this->isB2B2C() && Yii::$app->id == AppEnum::MERCHANT);
    }
}